{% extends "base.html" %}
{% load staticfiles %}
{% load analysis_tags %}
{% block content %}

    <div class="flex-nav">
        {% include "analysis/pages/nav-sidebar.html" %}
        <section class="flex-nav__body cuckoo-analysis" tabindex="0">

            <header class="page-header cuckoo-analysis__header">
                <h1>Dropped Files</h1>
            </header>

            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-8">
                        {% if report.analysis.dropped|length > 0 %}
                            {% for file in report.analysis.dropped %}
                                <div class="panel panel-default">
                                    <table class="table table-striped table-condensed table-fixed">
                                        <tr>
                                            <th class="col-md-1 text-right">Name</th>
                                            <td>
                                                <b>{{file.name}}</b>
                                                <div class="pull-right">
                                                    {% if file.object_id %}
                                                            <a href="{% url "analysis.views.file" "dropped" file.object_id %}" class="btn btn-primary btn-xs">
                                                            <span class="glyphicon glyphicon-save" aria-hidden="true"></span> Download
                                                            </a>
                                                            <a href="{% url "submission/dropped" report.analysis.info.id file.sha1 %}" class="btn btn-warning btn-xs">
                                                                <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Submit file
                                                            </a>
                                                    {% else %}
                                                        <div class="btn btn-default btn-xs"> Empty file or file not found</div>
                                                    {% endif %}
                                                </div>
                                            </td>
                                        </tr>
                                    </h4>
                                        {% if file.filepath %}
                                        <tr>
                                            <th class="text-right">Filepath</th>
                                            <td>{{ file.filepath }}</td>
                                        </tr>
                                        {% endif %}
                                        <tr>
                                            <th class="text-right">Size</th>
                                            <td>{{ file.size | sizeof_fmt }}</td>
                                        </tr>
                                        {% if file.pids %}
                                        <tr>
                                            <th class="text-right">Processes</th>
                                            <td>
                                                {% for pid in file.pids %}
                                                {{ pid }} (<b>{{ pid|process_name:report.analysis }}</b>)
                                                {% endfor %}
                                            </td>
                                        </tr>
                                        {% endif %}
                                        <tr>
                                            <th class="text-right">Type</th>
                                            <td>{{file.type}}</td>
                                        </tr>
                                        <tr>
                                            <th class="text-right">MD5</th>
                                            <td class="break-everywhere"><tt>{{file.md5}}</tt></td>
                                        </tr>
                                        <tr>
                                            <th class="text-right">SHA1</th>
                                            <td class="break-everywhere"><tt>{{file.sha1}}</tt></td>
                                        </tr>
                                        <tr>
                                            <th class="text-right">SHA256</th>
                                            <td class="break-everywhere"><tt>{{file.sha256}}</tt></td>
                                        </tr>
                                        <tr>
                                            <th class="text-right">CRC32</th>
                                            <td class="break-everywhere"><tt>{{file.crc32}}</tt></td>
                                        </tr>
                                        <tr>
                                            <th class="text-right">ssdeep</th>
                                            <td class="break-everywhere"><tt>{{file.ssdeep}}</tt></td>
                                        </tr>
                                        <tr>
                                            <th class="text-right">Yara</th>
                                            <td>
                                            {% if file.yara %}
                                                <ul style="margin-bottom: 0;">
                                                {% for sign in file.yara %}
                                                    <li>{{sign.name}} - {{sign.meta.description}}</li>
                                                {% endfor %}
                                                </ul>
                                            {% else %}
                                                None matched
                                            {% endif %}
                                            </td>
                                        </tr>
                                        <tr>
                                            <th class="text-right">VirusTotal</th>
                                            <td><a href="https://www.virustotal.com/en/file/{{file.sha256}}/analysis/">Search for analysis</a></td>
                                        </tr>
                                    </table>
                                </div>
                            {% endfor %}
                        {% else %}
                            <div class="alert alert-info"><b>Sorry!</b> No dropped files.</div>
                        {% endif %}
                    </div>
                </div>
            </div>

             <!-- footer replacement to avoid double scrollbars -->
            <footer class="flex-grid__footer spread-alignment">
                <p class="footnote">
                    &copy;2010-2018 <a href="https://www.cuckoosandbox.org" target="_blank">Cuckoo Sandbox</a>
                </p>
                <div class="logo">
                    <img src="{% static "graphic/cuckoo_inverse.png" %}" alt="Cuckoo Malware Analysis Sandbox" />
                    <a href="#">Back to Top</a>
                </div>
            </footer>

        </section>
    </div>

{% endblock %}
